package com.search;

import org.apache.lucene.search.ScoreDoc;

import java.util.Comparator;


/**
 * Esta clase clase implmenta un comparator sobre los ScoreDocs para ordenarlos
 * segun el score
 *
 * @author $author$
 * @version $Revision$
  */
public class ScoreDocComparator implements Comparator<ScoreDoc> {
    /**
     * DOCUMENT ME!
     *
     * @param scoreDoc1 DOCUMENT ME!
     * @param scoreDoc2 DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    @Override
    public int compare(ScoreDoc scoreDoc1, ScoreDoc scoreDoc2) {
        if (scoreDoc1.score < scoreDoc2.score) {
            return -1;
        }

        if (scoreDoc1.score > scoreDoc2.score) {
            return 1;
        }

        return 0;
    }

    /**
     * DOCUMENT ME!
     *
     * @param scoreDoc1 DOCUMENT ME!
     * @param scoreDoc2 DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public boolean equals(ScoreDoc scoreDoc1, ScoreDoc scoreDoc2) {
        if (scoreDoc1.score == scoreDoc2.score) {
            return true;
        }

        return false;
    }
}
